import { BasicColumn, BasicTable, FormSchema, useTable } from "@/components/Table";
import { useTranslation } from "react-i18next";
import { chargeApi } from "@/api/MedicalExamination/outpatientExpenses/charge";
import { formatDate } from "@/utils/util";
const index = () => {
	const { t } = useTranslation();
	const en_vi = "MedicalExamination.outpatientExpenses.charge";
	const schemas: FormSchema[] = [
		{
			label: t(`statisticalReport.outpatientPrescriptionFees.paymentTime`),
			field: "pmtTime",
			component: "RangePicker"
		}
	];
	const columns: BasicColumn[] = [
		{
			title: t(`${en_vi}.orderId`),
			dataIndex: "orderId"
		},
		{
			title: t(`${en_vi}.projectName`),
			dataIndex: "bizName"
		},

		{
			title: t(`${en_vi}.projectPriceYuan`),
			dataIndex: "bizPrice"
		},
		{
			title: t(`${en_vi}.discountAmountYuan`),
			dataIndex: "discountPrice"
		},
		{
			title: t(`${en_vi}.discountRatePercent`),
			dataIndex: "discountPercent"
		},
		{
			title: t(`${en_vi}.actualPaymentYuan`),
			dataIndex: "discountPercent",
			render: (_: any, record: any) => {
				return record.bizPrice - record.discountPrice;
			}
		},
		{
			title: t(`${en_vi}.paymentType`),
			dataIndex: "patOrders",
			render: (patOrders: any) => {
				if (patOrders.payType == 0) return t(`${en_vi}.cash`);
				if (patOrders.payType == 1) return t(`${en_vi}.socialSecurity`);
				if (patOrders.payType == 2) return t(`${en_vi}.bankCard`);
				return t(`${en_vi}.others`);
			}
		},
		{
			title: t(`${en_vi}.paymentTime`),
			dataIndex: "pmtTime",
			render: (pmtTime: any) => {
				return formatDate(new Date(pmtTime));
			}
		},
		{
			title: t(`${en_vi}.type`),
			dataIndex: "bizType",
			render: (bizType: any) => {
				if (bizType == 1) return t(`${en_vi}.inspection`);
				if (bizType == 2) return t(`${en_vi}.service`);
				if (bizType == 3) return t(`${en_vi}.medicine`);
				return "";
			}
		}
	];
	const [registerTable] = useTable({
		api: chargeApi.chargeList,
		columns,
		useSearchForm: true,
		formConfig: {
			labelWidth: 120,
			schemas,
			showActionButtonGroup: true,
			showAdvancedButton: false,
			baseColProps: { span: 6 },
			actionColOptions: { span: 24 }
		},
		bordered: true,
		beforeFetch: value => {
			console.log(value);
			return {
				...value,
				status: 1
			};
		}
	});
	return (
		<div>
			<div className="page-content">
				<BasicTable register={registerTable}></BasicTable>
			</div>
		</div>
	);
};

export default index;
